<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="utf-8" />
<head>
<title>监测管理 <?php echo $this->config->item('title');?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
	href="<?php echo base_url()?>public/css/bootstrap.min.css">
<link rel="stylesheet"
	href="<?php echo base_url()?>public/css/select2/select2.css">
<link rel="stylesheet"
	href="<?php echo base_url()?>public/css/select2/select2-bootstrap.css">
<link rel="stylesheet"
	href="<?php echo base_url()?>public/css/style.css">
<script src="<?php echo base_url()?>public/js/jquery-2.0.2.min.js"></script>
<script src="<?php echo base_url()?>public/js/bootstrap.min.js"></script>
<script src="<?php echo base_url()?>public/js/bootstrap-confirm.js"></script>
<script src='<?php echo base_url()?>public/js/ssi_common.js'></script>
<script src='<?php echo base_url()?>public/js/select2.min.js'></script>
<script src='<?php echo base_url()?>public/js/select2_locale_zh-CN.js'></script>
<script type="text/javascript">
		$(document).ready(function(){
			$("#parent1").select2();
			$("#parent2").select2();
			$("#dianwei").select2();
			$("#province").change(function(){
				$("#city").html('<option value="">请选择</option>');
				$("#region").html('<option value="">请选择</option>');
			
				var province =$("#province").val();
				if(!province){
					return false;
				}
				$.getJSON("<?php echo base_url()."index.php/sys_region_manage/get_regions"?>", { region_id: province }, function(json){
					if (json.length == 0) {
						return;
					}
					for(var i = 0, len = json.length; i<len; ++i){
						var region = json[i];
						$("#city").append("<option value=" + region.region_id + ">" + region.region_name + "</option>");
					}
				});
			});
			$("#city").change(function(){
				$("#region").html('<option value="">请选择</option>');

				var city =$("#city").val();
				$.getJSON("<?php echo base_url()."index.php/sys_region_manage/get_regions"?>", { region_id: city }, function(json){
					if (json.length == 0) {
						return;
					}
					for(var i = 0, len = json.length; i<len; ++i){
						var region = json[i];
						$("#region").append("<option value=" + region.region_id + ">" + region.region_name + "</option>");
					}
				});
			});


			$("#brand").select2({
			    placeholder: "搜索品牌",
			    minimumInputLength: 1,
			    ajax: {
			        url: "<?php echo base_url()?>index.php/sys_brand_manage/search_brand",
			        dataType:'json', 
			        data: function (term, page) {
			            return {
			                keyword: term
			            };
			        },
			        results: function (data, page) {
			            return {results: data.brand};
			        }
			    },
			    formatResult: formatBrandText,
			    formatSelection: formatBrand,  
			    escapeMarkup: function (m) { return m; } 
			});
			function formatBrand(brand) {
			    return brand.name;
			}
			function formatBrandText(brand){
				var itemFmt =brand.name; 
			     return itemFmt;  
			}  

			$(".bigdrop1").find(".select2-chosen").text("<?php echo $search['brand_name']?>");
		});

		function onIndustryChanged(){
			var parent1 = $("#parent1");
			var index = $("#parent1").get(0).selectedIndex;
			var parent2 = $("#parent2");
			parent2.html("<option value=''>请选择</option>");
			parent2.select2();
			if (index == 0) {
				return;
			}
			var parentid = parent1.val();
			$.getJSON("<?php echo base_url()."index.php/sys_industry_manage/get_industrys"?>", { industry_id: parentid }, 
				function(json){
				for(var i = 0, len = json.length; i<len; ++i){
					var category = json[i];
					parent2.append("<option value=" + category.industry_id + ">" + category.industry_name + "</option>");
				}
				parent2.select2();
			});
		}
	</script>
</head>
<body>
	<div role="navigation" class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand">SSI后台管理系统</a>
			</div>
			<div class="collapse navbar-collapse navbar-right">
				<ul class="nav navbar-nav">
					<li><a href="<?php echo base_url()?>" class="navbar-link">首页</a></li>
					<li><a
						href="<?php echo base_url()."index.php/common_login_user_set"?>"
						class="navbar-link">超级管理员</a></li>
					<li><a
						href="<?php echo base_url()?>index.php/common_login_manage/logout"
						class="navbar-link">退出</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-xs-3">
				<?php echo $user_menu?>
			</div>
			<div class="col-sm-9">
				<div class="panel panel-default">
					<div class="panel-body">
						<form action="" method="get">
							<table width="100%" class="search_table">
								<tr>
									<td width="50%">所属区域: <select id="province" name="province"
										class="form-control">
											<option value="">请选择</option>
									<?php if ($province_list!=null) {	foreach ($province_list as $province){	?><option
												value="<?php echo $province['region_id']?>"
												<?php echo $province['region_id']==$search['province']?'selected="selected"':''?>><?php echo $province['region_name']?></option>
									<?php
										}
									}
									?>
									</select> <select id="city" name="city" class="form-control">
											<option value="">请选择</option>
									<?php if ($city_list!=null) {	foreach ($city_list as $city){	?><option
												value="<?php echo $city['region_id']?>"
												<?php echo $city['region_id']==$search['city']?'selected="selected"':''?>><?php echo $city['region_name']?></option>
									<?php
										}
									}
									?>
									</select> <select id="region" name="region"
										class="form-control">
											<option value="">请选择</option>
									<?php if ($region_list!=null) {	foreach ($region_list as $region){	?><option
												value="<?php echo $region['region_id']?>"
												<?php echo $region['region_id']==$search['region']?'selected="selected"':''?>><?php echo $region['region_name']?></option>
									<?php
										}
									}
									?>
									</select>

									</td>
									<td>媒体分类: <select id="media_type_id" name="media_type_id"
										class="form-control full_td">
											<option value="">请选择</option>
										<?php if ($media_type_list!=null) {	foreach ($media_type_list as $media_type){	?><option
												value="<?php echo $media_type['media_type_id']?>"
												<?php echo $media_type['media_type_id']==$search['media_type_id']?'selected="selected"':''?>><?php echo $media_type['media_type_name']?></option>
										<?php
											}
										}
										?>
										</select>
									</td>
								</tr>
								<tr>
									<td>行业品类: <select id="parent1" name="industry"
										class="form-control" onchange="onIndustryChanged()"
										style="width: 152px;">
											<option value="">请选择</option>
													<?php
													
if ($industry_list != null) {
														foreach ( $industry_list as $industry ) {
															?>
																<option value="<?php echo $industry['industry_id']?>"
												<?php echo $industry['industry_id']==$search['industry']?'selected="selected"':'';?>><?php echo $industry['industry_name']?></option>
															<?php
														}
													}
													?>
												</select> <select id="parent2" name="industry_category"
										class="form-control" style="width: 152px;">
											<option value="">请选择</option>
												<?php
												
if ($industry_category_list != null) {
													foreach ( $industry_category_list as $industry_category ) {
														?>
																<option
												value="<?php echo $industry_category['industry_id']?>"
												<?php echo $industry_category['industry_id']==$search['industry_category']?'selected="selected"':'';?>><?php echo $industry_category['industry_name']?></option>
															<?php
													}
												}
												?>
												</select>
									</td>
									<td>媒体类型: <select name="media_type"
										class="form-control full_td">
											<option value="">请选择</option>
											<option value="led"
												<?php echo $search['media_type']=="led"?'selected="selected"':''?>>市区LED大牌</option>
											<option value="common"
												<?php echo $search['media_type']=="common"?'selected="selected"':''?>>市区常规大牌</option>
											<option value="highway"
												<?php echo $search['media_type']=="highway"?'selected="selected"':''?>>高速公路大牌</option>
											<option value="airport"
												<?php echo $search['media_type']=="airport"?'selected="selected"':''?>>机场大牌</option>
									</select>
									</td>
								</tr>
								<tr>
									<td>品 牌: <input type="text" id="brand" name="brand"
										class="bigdrop1 form-control " style="width: 220px;"
										value="<?php echo $search['brand']?>" /></td>
									<td>监测时间: <input type="date" name="monitor_time"
										value="<?php echo $search['monitor_time']?>"
										class="form-control full_td">
									</td>
								</tr>
								<tr>
									<td>发布产品: <input type="text" name="product_name"
										value="<?php echo $search['product_name']?>"
										class="form-control full_td">
									</td>
									<td>点位属性: <select multiple name="dianwei[]" id="dianwei"
										style="width: 220px;">
											<option value="circle"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "circle") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>商圈</option>
											<option value="road"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "road") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>主干道</option>
											<option value="market"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "market") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>专业市场</option>
											<option value="station"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "station") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>火车站</option>
											<option value="stop"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "stop") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>汽车站</option>
											<option value="venues"
												<?php
												
if ($search ['dianwei']) {
													foreach ( $search ['dianwei'] as $dianwei ) {
														if ($dianwei == "venues") {
															echo 'selected="selected"';
															break;
														}
													}
													;
												}
												?>>大型场馆</option>
									</select>
									</td>
								</tr>
								<tr>
									<td colspan="2" align="right"><input type="submit"
										class="btn btn-primary" value="搜索"></td>
								</tr>
							</table>
						</form>
					</div>
				</div>
				<div class="panel panel-default">
					<div class="panel-heading">
						<p>
						<?php if ($add_monitor) {?>
							&nbsp;<a
								href="<?php echo base_url()."index.php/media_monitor_manage/add_monitor"?>"
								class="btn btn-link pull-right"><span
								class="glyphicon glyphicon-plus"> </span><span> 添加</span> </a>
						<?php }?>
						</p>
					</div>
				</div>
				<div class="panel-body">
				<?php if ($query_monitor) {?>
					<table class="table table-hover">
						<thead>
							<tr>
								<td class="col-md-2"><b>监测媒体</b></td>
								<td class="col-md-2"><b>行业品类</b></td>
								<td class="col-md-2"><b>产品名称</b></td>
								<td class="col-md-2"><b>监测时间</b></td>
								<td class="col-md-3"><b>操作</b></td>
							</tr>
						</thead>
						<tbody>
							<?php
					
if ($monitor_list != null) {
						foreach ( $monitor_list as $monitor ) {
							?>
							<tr>
								<td>
									<?php echo $monitor['media_id']?>
								</td>
								<td><?php echo $monitor['industry_name']?>
								<?php
							
if ($monitor ['industry_name'] != $monitor ['industry_category_name']) {
								echo " / " . $monitor ['industry_category_name'];
							}
							?>
								</td>
								<td><?php echo $monitor['product_name']?>
								</td>
								<td><?php echo substr($monitor['monitor_time'],0,10)?>
								</td>
								<td><a title="查看"
									href="<?php echo base_url()."index.php/media_monitor_manage/query_monitor?monitor_id=".$monitor['monitor_id']?>"
									class="btn btn-link "> <span
										class="glyphicon glyphicon-eye-open"></span>
								</a> 
								<?php if ($update_monitor) {?>
								<a title="编辑"
									href="<?php echo base_url()."index.php/media_monitor_manage/edit_monitor?monitor_id=".$monitor['monitor_id']?>"
									class="btn btn-link"> <span class="glyphicon glyphicon-pencil"></span>
								</a>
								<?php }?>
								<?php if ($update_monitor_time) {?>
								<a title="编辑监测日期"
									href="<?php echo base_url()."index.php/media_monitor_manage/edit_monitor_time?monitor_id=".$monitor['monitor_id']?>"
									class="btn btn-link"> <span
										class="glyphicon glyphicon glyphicon-calendar"></span>
								</a>
								<?php }?>
								<?php if ($delete_monitor) {?>
								<a title="删除"
									rel="<?php echo base_url()."index.php/media_monitor_manage/delete_monitor?monitor_id=".$monitor['monitor_id']?>"
									class="btn btn-link confirm"> <span
										class="glyphicon glyphicon-trash"></span>
								</a>
								<?php }?>
								</td>
							</tr>
							<?php
						
}
					}
					?>
						</tbody>
					</table>
					<?php }?>
				</div>
			</div>
		</div>
	</div>
	</div>
	<script>$('.confirm[rel]').each(function() {
 $(this).confirm({
  'title' : '是否确认删除',
  'message' : '该操作无法恢复，请再次确认！',
  'action' : $(this).attr('rel')
 });
});</script>
	<div class="back-to" id="toolBackTop">
		<a title="返回顶部" onclick="window.scrollTo(0,0);return false;"
			href="#top" class="back-top"> 返回顶部</a> <a title="返回底部"
			onclick="window.scrollTo(0,document.body.scrollHeight);return false;"
			href="#bottom" class="back-bottom"> 返回底部</a>
	</div>
</body>
</html>
